﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;

namespace Helpers
{
    public class MongoOptions
    {
        public const string SectionName = "mongo";
        /// <summary>
        /// 数据库连接串
        /// </summary>
        [Required]
        public string Connection { get; set; }
        /// <summary>
        /// 数据库名称
        /// </summary>
        [Required]
        public string DatabaseName { get; set; }
        /// <summary>
        /// 仓储所在的程序集名称,非必填项,默认启动时会自动发现仓储类并注册
        /// </summary>
        public List<string> RepositoryAssemblyNames { get; set; }
        /// <summary>
        /// 是否自动创建索引
        /// </summary>
        public bool IsAutoCreateIndex { get; set; } = false;
        /// <summary>
        /// 自动创建索引的仓储
        /// </summary>
        [JsonIgnore]
        public Type[] AutoCreateIndexRepositories { get; set; }
        public IEnumerable<string> AutoCreateIndexRepositoriesString => AutoCreateIndexRepositories?.Select(x => x.Name);
    }
}
